package mo.leetcode_top;

public class L53 {

    public int maxSubArray(int[] nums) {
        int res = Integer.MIN_VALUE;
        int cur = 0;
        for (int num : nums) {
            cur = Math.max(cur+num, num);
            res = Math.max(cur, res);
        }
        return res;
    }

    public static void main(String[] args) {
        L53 test = new L53();
        System.out.println(test.maxSubArray(new int[]{5,4,-1,7,8}));
    }
}
